package feng.demo.service;

import com.fasterxml.jackson.databind.ObjectMapper;
import feng.demo.dao.PermDao;
import feng.demo.entity.Perm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

@Component
public class RedisAddServiceImpe {
    @Autowired
    PermDao permDao;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    RedisTemplate redisTemplate;
    @PostConstruct
    public void addRedis()throws Exception{
//        List<Perm> list = permDao.findAll();
//        for (Perm p:list) {
//            String id = objectMapper.writeValueAsString(p.getPermid());
//            String perm = objectMapper.writeValueAsString(p);
//            redisTemplate.opsForHash().put("perm::",id,perm);
//        }

    }
}
